home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / comm / cnet / labelmake.lzh / maillist.c < prev    next >
C/C++ Source or Header  |  1991-08-15  |  4KB  |  149 lines

  1. /****************************************************************************
  2.                                  MailList Maker
  3.  
  4.  DOX: Run it as a C Pfile.  Doesn't get much harder than that.  It will zoom
  5.  thru your userlist and make a textfile in RAM: (called "maillist") which you
  6.  may then copy to prt: to print out mailing labels.
  7.  
  8.  However - this makes it of ALL ACOUNTS!  If they have no address, then you
  9.  can A: Edit the file and remove them, or B: waste the label.
  10.  
  11.  AGREEMENT OF USE: This file may only be run on legal C-Net AMIGA systems.
  12.  This source code and it's executable are ONLY to be distributed in this
  13.  original form with **NONE** of your modifications.  You may edit this for
  14.  your own use, but not re-distribute those changes.
  15.  
  16.  I will not be held responsible if this erases your hard drive, crashes your
  17.  computer, etc... blah blah blah, there, my butt is covered.  No more legal
  18.  talk, I promise!
  19.  ****************************************************************************
  20.        Copyright © 1991 The Brazilian / Bob Maple      //\ Software
  21.  ****************************************************************************
  22.  I can be reached in the following ways:        USENET: bmaple@isis.cs.du.edu
  23.                          FW ID#: 360/The Brazilian
  24.                          BBS   : 303/697-8156 [14400]
  25.  ****************************************************************************/
  26.  
  27.  
  28. struct MsgPort  *replyp;
  29. struct CPort    *cport;
  30. struct CMessage  cmess;
  31.  
  32. struct   MainPort  *myp;
  33. struct   PortData  *z;
  34.  
  35. main( int argc, char **argv )
  36. {
  37.  
  38.    FILE *input;
  39.    FILE *output;
  40.    int i;
  41.  
  42.    if( argc<2 || !(cport = (struct CPort *)FindPort( argv[1] )) ) {
  43.       printf("Must be ran as a C-Net Pfile!\n");
  44.       exit(0);
  45.    }
  46.  
  47.    if( !(replyp=CreatePort( 0,0 )) )
  48.       exit(0);
  49.  
  50.    cmess.cn_Message.mn_ReplyPort   = replyp;
  51.    cmess.cn_Message.mn_Length      = sizeof( struct CMessage );
  52.    cmess.cn_Message.mn_Node.ln_Name= "cstuff";
  53.  
  54.  
  55.    if( cport->ack != 97 ) {
  56.        cport->ack = 1;
  57.        goto err;
  58.    }
  59.  
  60.    cport->ack = 0;
  61.  
  62.    z    =   cport->zp;
  63.    myp  =   cport->myp;
  64.  
  65.    /* PLEASE DO NOT REMOVE THIS!  SHOW A LITTLE RESPECT... I WOULDN'T RIP
  66.       YOUR NAME OUT OF YOUR OWN PROGRAM.  */
  67.  
  68.    PutText( "\\f1\\cdMailList Maker\n\\c5v1.0 (c) 1991 The Brazilian\n" );
  69.    
  70.    EnterLine( 1, 1, "\n\\cfDo you really want to do this?: \\c7" );
  71.    if( *z->InBuffer == 'Y' )
  72.    {
  73.    
  74.      PutText( "\n\\caWorking.. [    ]" );
  75.      
  76.      if( (input = fopen( "system:bbs.udata", "r" )) == NULL )
  77.      {
  78.        PutText( "Error! Couldn't find userfile!!!\n" );
  79.        goto exit;
  80.      }
  81.      
  82.      output = fopen( "ram:maillist", "w" );
  83.      
  84.      for( i=1; i <= *myp->Nums; i++ )
  85.      {
  86.        sprintf( z->ABuffer, "\\<5%4d]", i ); PutA();
  87.  
  88.        ReadAccount( i, &z->user2 );
  89.        
  90.        fprintf( output, "%s\n%s\n%s  %s\n\n\n\n", z->user2.RealName,  
  91.                         z->user2.Address, z->user2.CityState, z->user2.ZipCode );
  92.      }
  93.      fclose( input );
  94.      fclose( output );
  95.      
  96.    }    
  97.  
  98. exit:
  99.       ShutDown( NULL );
  100.  
  101. err:  DeletePort( replyp );
  102.       exit(0);
  103. }
  104.  
  105. void ShutDown( char *spawn )
  106. {
  107.    if( spawn )
  108.       strcpy( z->CSpawn, spawn );
  109.  
  110.    CallHost( 0 );
  111. }
  112.  
  113. void CallHost( UBYTE c )
  114. {
  115.    cmess.command = c;
  116.    PutMsg  ( (struct MsgPort *)cport, (struct Message *)&cmess );
  117.    WaitPort( replyp );
  118.    GetMsg  ( replyp );
  119. }
  120.  
  121. void PutText( UBYTE *text )
  122. {
  123.    cmess.arg1 = (ULONG)text;   /* text to print      */
  124.    CallHost( 1 );
  125. }
  126.  
  127. void PutA( void )
  128. {
  129.    PutText( z->ABuffer );
  130. }
  131.  
  132. LONG EnterLine( UBYTE len, SHORT flags, UBYTE *prompt )
  133. {
  134.    cmess.arg1 = (ULONG)len;
  135.    cmess.arg2 = (ULONG)flags;
  136.  
  137.    cmess.arg3 = (ULONG)prompt;
  138.    CallHost( 2 );
  139.    return( (LONG)strlen( z->InBuffer ));
  140. }
  141.  
  142. void ReadAccount( SHORT id, struct UserData *user )
  143. {
  144.    cmess.arg1 = (ULONG)id;
  145.    cmess.arg2 = (ULONG)user;
  146.    CallHost( 11 );
  147. }
  148.  
  149.